package com.dyz.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dyz.domain.Config;
import com.dyz.domain.WebConfig;
import com.dyz.mapper.ConfigMapper;
import com.dyz.model.Result;
import com.dyz.service.IConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 平台配置信息 服务实现类
 * </p>
 *
 * @author dyz
 * @since 2025-04-19
 */
@Service
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements IConfigService {
    @Resource
    private ConfigMapper configMapper;

    @Override
    public Result<?> getConfigList(Page<Config> page, String name, String type, String code) {
      Page<Config> configPage= configMapper.getConfigList(page, name, type, code);
        return Result.success(configPage);
    }

    @Override
    public Result<?> removeConfigs(String[] ids) {
        if(ids==null||ids.length==0){
            return Result.fail("请选择要删除的数据");
        }
        List<Long> idList = Arrays.stream(ids).map(Long::parseLong).collect(Collectors.toList());
        if(removeByIds(idList)){
            return Result.success("删除成功");
        }else{
            return Result.fail("删除失败");
        }
    }
}
